#pragma once

#include "TypedElement.h"

#include "Type.h"

namespace uml {

void TypedElement::fromJson(const QJsonObject& json, QStringList& errorList) {
    if (json.isEmpty()) {
        return;
    }

    PartialElement::fromJson(json, errorList);
    type_ = JsonSerializable::create<Type>(json.value("type"), errorList);

}

void TypedElement::toJson(QJsonObject& json) {
    PartialElement::toJson(json);
    if (type_) {
        QJsonObject type_json;
        type_->toJson(type_json);
        json.insert("type", type_json);
    }
}

/// <summary>
/// type getter
/// The type of the TypedElement.
/// </summary>
shared_ptr<Type> TypedElement::type() const {
    return type_;
}

/// <summary>
/// type setter
/// The type of the TypedElement.
/// </summary>
void TypedElement::setType(shared_ptr<Type> value) {
    type_ = value;
}

} // namespace uml
